package com.nulstudio.cloud.account.controller;

import com.nulstudio.cloud.account.domain.vo.PersonalInformationVo;
import com.nulstudio.cloud.account.request.UpdatePersonalInformationRequest;
import com.nulstudio.cloud.account.service.PersonalInformationService;
import com.nulstudio.cloud.common.util.NulResult;
import jakarta.annotation.Resource;
import org.springframework.lang.NonNull;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/profile")
public class PersonalInformationController {

    @Resource
    @NonNull
    private PersonalInformationService personalInformationService;

    @GetMapping
    @NonNull
    public NulResult<PersonalInformationVo> information() {
        return NulResult.response(personalInformationService.getCurrentPersonalInformation());
    }

    @PutMapping
    @NonNull
    public NulResult<Void> update(@RequestBody @NonNull UpdatePersonalInformationRequest updatePersonalInformationRequest) {
        personalInformationService.updateCurrentPersonalInformation(updatePersonalInformationRequest.name(), updatePersonalInformationRequest.gender());
        return NulResult.response();
    }
}
